<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib  uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="css/oacss.css"  rel="stylesheet" type="text/css" />
<link href="css/rightList.css"  rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/openwindow.js"></script>
<script type="text/javascript">
	function page(currentPage){
		$("#pageId").val(currentPage);
		document.pageForm.submit();
	}
function clearInfo(){
	$("#name").val("");
	document.searchForm.submit();
}	

function initadd(){
	var url="initRole.action";
	openWindow(url,650,200);
}	
function checkAll(){
	var all=$("#all");
	var checks=$("input[name='ids']");
	if(all.attr("checked")){
		checks.attr("checked","checked");
	}else{
		checks.attr("checked","");
	}
}

function deleteUser(){
	var arry="";
	var count=0;
	var checks=$("input[name='ids']");
	for(var i=0;i<checks.length;i++){
		if(checks[i].checked){
			if(arry==''){
			arry+="ids="+checks[i].value;
			}else{
			arry+="&ids="+checks[i].value;
			}
			count++;
		}
	}
	if(count==0){
		alert("请选择要删除的数据！");
		return;
	}
	if(confirm("确定要删除？")){
		$.post("deleteRole.action",arry,function(data){
			if(data=="success"){
				alert("删除数据成功！");
				window.location.reload();
			}else{
				alert("删除数据失败！");
			}
		});
	}
}

function updateRole(id){
	var url="getRoleInfo.action?roleId="+id;
	openWindow(url,650,200);
}

</script>

</head>

<body  style="overflow-x:hidden;">
<div style="height:50px; background:url(image/TitleSearch.jpg) repeat-x;margin-left: 8px;margin-right: 15px">
<form action="roleManager.action" method="post" name="searchForm">
<table><tr><td>
<div style="margin-top:8px">
&nbsp;&nbsp;&nbsp;&nbsp;角色名称：<input type="text" style="height: 20px" id="name" name="name" value="${name}"/>
<input type="submit"  value="搜索"  style=" width:80px;background:url('image/but_1.gif');  line-height:20px" />
<input type="button" onclick="clearInfo();"  value="清除"  style="width:80px;background: url('image/but_1.gif'); line-height:20px" /></div>
</td></tr>
</table>
</form>
</div>
<table style="float:right;margin-right: 10px">
<tr><td>
<input type="button"  onclick="initadd()" value="添加"  style="width:80px;background: url('image/but_1.gif');line-height:20px;float:right" />
</td><td><input type="button" onclick="deleteUser()"  value="删除"  style="width:80px;background:url('image/but_1.gif'); line-height:20px; float:right" /></td></tr>
</table>
<table class="table" cellspacing="1" cellpadding="2" width="98%"  border="0" style="margin-left: 8px;margin-right: 15px">
	<tr>
	<th align="left" class="bg_tr" width="5%"><input type="checkbox" onclick="checkAll()" id="all"></th>
	<th align="left" class="bg_tr" width="10%">序号</th>
	<th align="left" class="bg_tr">角色名称</th>
	<th align="left" class="bg_tr" width="15%">操作</th>
	</tr>
	<c:if test="${empty roleList}">
	<tr>
	    <td class="td_bg" colspan="7">没有相关记录！</td>
	    </tr>
	</c:if>
	<c:forEach items="${roleList}" var="role">
    <tr>
     	<td  class="td_bg"><input type="checkbox" name="ids"  value="${role.id}"></td>
     	<td class="td_bg">${role.id}</td>
	    <td class="td_bg">${role.name}</td>
	    <td class="td_bg">&nbsp;&nbsp;&nbsp;<a href="" style="color: #FF6600;font-weight: bold">用户指定</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	    <img alt="修改" onclick="updateRole('${role.id}')" src="image/operate_update.gif" style="cursor: pointer">
	    </td>
	    </tr>
    </c:forEach>
</table>
<div style="margin-right: 30px">
<form action="roleManager.action" method="post" name="pageForm">
<input type="hidden" name="name" value="${name}">
<input type="hidden" id="pageId" name="currentPage"> 
<%@include file="../page/page.jsp" %>
</form>
</div>
</body>
</html>